<?php
class Application_Model_Resource_FinderFactory
{
    const USER_FINDER = 1;
    const ACCOUNT_FINDER = 2;
    const BLOG_CATEGORY = 3;
    const BLOG = 4;

    private static $_finders = array();

    private function construct()
    {

    }

    public static function getFinder($_name)
    {
        $finder = null;
        if (isset(self::$_finders[$_name])) {
            $finder = self::$_finders[$_name];
        } else {
            switch ($_name) {
                case self::USER_FINDER :
                    $finder = new Application_Model_Resource_User_Table();
                    $finder->setRowClass('Application_Model_User');
                    break;

                case self::ACCOUNT_FINDER :
                    $finder = new Application_Model_Resource_Account_Table();
                    $finder->setRowClass('Application_Model_Account');
                    break;

                case self::BLOG_CATEGORY :
                    $finder = new Application_Model_Resource_Blog_Category_Table();
                    $finder->setRowClass('Application_Model_Blog_Category');
                    break;

                case self::BLOG :
                    $finder = new Application_Model_Resource_Blog_Post_Table();
                    $finder->setRowClass('Application_Model_Blog');
                    break;

                default:
                    throw new Application_Model_Resource_Exception("The finder can not found.");
            }
            self::$_finders[$_name] = $finder;
        }

        return $finder;
    }
}
?>